home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / lib / X11 / init_tclMotif.tcl < prev    next >
Text File  |  1995-07-17  |  941b  |  37 lines

  1. # This init file redefines the "unknown" command so that
  2. # it will use pattern-matching like that of Xt for commands.
  3. # This allows use of shorter widget names e.g. *myBtn
  4. # Commands that are not abbreviations this way are passed
  5. # onto the old unknown. To allow for a stack of "unknown"
  6. # commands, unknowns are relabelled unknown.old, unknown.old.old, etc
  7. #
  8.  
  9. global tclMotif_unknown
  10.  
  11. set tclMotif_unknown "unknown"
  12.  
  13. while {[info commands $tclMotif_unknown] != ""} {
  14.     set tclMotif_unknown $tclMotif_unknown.old
  15. }
  16.  
  17. rename unknown $tclMotif_unknown
  18.  
  19. proc unknown {name args} {
  20.     global tclMotif_unknown
  21.  
  22.     set cmds [info commands $name]
  23.     set len [llength $cmds]
  24.     if {$len == 0} {
  25.     # no match, pass to old unknown
  26.     set cmd "uplevel 1 $tclMotif_unknown $name $args"
  27.     eval $cmd
  28.     }
  29.     if {$len > 1} {
  30.     error "non-unique command \"$name\" matches \"$cmds\""
  31.     }
  32.  
  33.     # unique abbreviation:
  34.     return [uplevel $cmds $args]
  35. }
  36.